package l1j.opqlo.Server.etcitem;

import static l1j.server.server.model.skill.L1SkillId.STATUS_FLOATING_EYE;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_PacketBox;
import l1j.server.server.serverpackets.S_ServerMessage;

public class Food {

	/** 肉類(飽食度物品) */

	/*
	 * } else if (itemId == 40056 || itemId == 40057 || itemId == 40059 ||
	 * itemId == 40060 || itemId == 40061 || itemId == 40062 || itemId == 40063
	 * || itemId == 40064 || itemId == 40065 || itemId == 40069 || itemId ==
	 * 40072 || itemId == 40073 || itemId == 140061 || itemId == 140062 ||
	 * itemId == 140065 || itemId == 140069 || itemId == 140072 || itemId ==
	 * 41296 || itemId == 41297 || itemId == 41266 || itemId == 41267 || itemId
	 * == 41274 || itemId == 41275 || itemId == 41276 || itemId == 41252 ||
	 * itemId == 49040 || itemId == 49041 || itemId == 49042 || itemId == 49043
	 * || itemId == 49044 || itemId == 49045 || itemId == 49046 || itemId ==
	 * 49047) {
	 */
	public static void begin(final L1PcInstance pc,
			final L1ItemInstance l1iteminstance) {
		// 肉類

		pc.getInventory().removeItem(l1iteminstance, 1);
		// XXX 食べ物每の滿腹度(100單位で變動)
		short foodvolume1 = (short) (l1iteminstance.getItem().getFoodVolume() / 10);
		short foodvolume2 = 0;
		if (foodvolume1 <= 0) {
			foodvolume1 = 5;
		}
		if (pc.get_food() >= 225) {
			pc.sendPackets(new S_PacketBox(S_PacketBox.FOOD, (short) pc.get_food()));
		} else {
			foodvolume2 = (short) (pc.get_food() + foodvolume1);
			if (foodvolume2 <= 225) {
				pc.set_food(foodvolume2);
				pc.sendPackets(new S_PacketBox(S_PacketBox.FOOD, (short) pc.get_food()));
			} else {
				pc.set_food((short) 225);
				pc.sendPackets(new S_PacketBox(S_PacketBox.FOOD, (short) pc.get_food()));
			}
		}
		if (l1iteminstance.getItemId() == 40057) { // フローティングアイ肉
			pc.setSkillEffect(STATUS_FLOATING_EYE, 0);
		}
		pc.sendPackets(new S_ServerMessage(76, l1iteminstance.getItem().getIdentifiedNameId()));

	}
}
